<?php

namespace app\modules\frontend\controllers;

use app\lib\DataMessage;
use Yii;
use yii\web\Controller;

class BaseController extends Controller {
    public function beforeAction($action) {
        Yii::$app->language = 'zh-CN';
        return parent::beforeAction($action);
    }

    public function redirect($url, $statusCode = 302) {
        if(Yii::$app->request->isAjax) {
            return DataMessage::initFail(302, '', $url);
        } else {
            return parent::redirect($url, $statusCode);
        }
    }
}
